/**
 * Created with JetBrains PhpStorm.
 * User: xiaoyan
 * Date: 15-5-9
 * Time: 下午8:54
 * To change this template use File | Settings | File Templates.
 */
var dx = layer = typeof(layer) == "undefined" ? parent.layer : window.layer;
var util = {
    resize:function(who,width,height){
        var index = util.getIndex(who); //获取窗口索引
        if(index != -1){
            var conf = {};
            if(width){conf['width'] = width;}
            if(height){conf['width'] = height;}
            dx.setSize(index, conf);
        }
    },
    setTitle:function(who,title){
        var index = util.getIndex(who); //获取窗口索引
        if(index != -1){
            dx.setTitle(index, title);
        }
    },
    getIndex:function(who){
        if(typeof(who) == "undefined" && window != parent) who = window;
        if(who && who.name){
            var index = dx.getFrameIndex(who.name); //获取窗口索引
            return index;
        }
        return -1;
    },
    close:function(who,tag){
        var index = util.getIndex(who); //获取窗口索引
        if(index != -1){dx.close(index,tag);}
    }
}